package cn.iocoder.yudao.module.trade.controller.app.order.vo.item;

import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.framework.common.validation.Mobile;
import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.util.List;

@Data
public class TradeOrderCreateReqVO {
    @Schema(description = "商品项数组", requiredMode = Schema.RequiredMode.REQUIRED)
    private List<Item> items;


    @Data
    @Schema(description = "用户 App - 商品项")
    @Valid
    public static class Item {
        @Schema(description = "购物车编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
        private Long cartId;
        
        @Schema(description = "商品 SKU 编号", example = "2048")
        @NotNull(message = "商品 SKU 编号不能为空")
        private Long skuId;

        @Schema(description = "购买数量", example = "1")
        @Min(value = 1, message = "购买数量最小值为 {value}")
        private Integer count;

        @Schema(description = "备注", example = "这个是我的订单哟")
        private String remark;
        // ========== 配送相关相关字段 ==========
        @Schema(description = "配送方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
        @InEnum(value = DeliveryTypeEnum.class, message = "配送方式不正确")
        private Integer deliveryType;

        @Schema(description = "收件地址编号", example = "1")
        private Long addressId;

        @Schema(description = "自提门店编号", example = "1088")
        private Long pickUpStoreId;
        @Schema(description = "收件人名称", example = "芋艿") // 选择门店自提时，该字段为联系人名
        private String receiverName;
        @Schema(description = "收件人手机", example = "15601691300") // 选择门店自提时，该字段为联系人手机
        @Mobile(message = "收件人手机格式不正确")
        private String receiverMobile;

    }
}
